<%@ include file="/jsp/include.jsp" %>
<!DOCTYPE html>
<html>
<head><title>User List</title></head>
<link type="text/css" href="../css/ui-lightness/jquery-ui-1.8.23.custom.css" rel="stylesheet" />
<body>
	<h3>Users</h3>
	<c:forEach items="${users}" var="user" varStatus="idx">
		<div onClick="chooseUser(${idx.index})">
			<span><c:out value="${user.name}"/></span>&nbsp;<span><c:out value="${user.password}"/></span>&nbsp;
			<span><c:out value="${user.description}"/></span>&nbsp;<span><c:out value="${user.email}"/></span>&nbsp;
			<span><c:out value="${user.phoneNo}"/></span>&nbsp;<span><c:out value="${user.createTime}"/></span>&nbsp;
			<span><c:out value="${user.updateTime}"/></span>&nbsp;
			<input type="hidden" id="userId${idx.index}"  value="${user.userId}">   
		</div>
	</c:forEach>
	<br>
	<div>
		<button id="adduser">Add</button>
		<button id="deleteuser">Delete</button>
	</div>
</body>
<script type="text/javascript" src="../js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.8.23.custom.min.js"></script>
<script type="text/javascript" src="../js/userlist.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		var userList = new UserList();
		userList.init();
	});
	
	function chooseUser(index)
	{
		var id = $("#userId" + index).val();
		console.log("index:" + index + ",id:" + id);
		location.href= "/springmvc/user/getUser.do?id=" + id;
	}
	
</script>
</html>